﻿#include "KItemUI.h"
#include "Tools.h"

KItemUI *KItemUI::_instance = nullptr;

KItemUI::KItemUI(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
}

KItemUI::~KItemUI()
{
	_instance = nullptr;
}

KItemUI *KItemUI::Instance(QWidget *parent /*= Q_NULLPTR*/)
{
	if (_instance == nullptr)
	{
		_instance = new KItemUI(parent);
	}
	return _instance;
}

void KItemUI::SetValue(const MData::KLineItem &pItem)
{
	std::string kTimeStr = Tools::DateTimeStamp2Str(pItem.UpdateTime);
	ui.ledt_kTime->setText(QString::fromLocal8Bit(kTimeStr.c_str()));
	ui.ledt_high->setText(QString::number(pItem.High));
	ui.ledt_low->setText(QString::number(pItem.Low));
	ui.ledt_open->setText(QString::number(pItem.Open));
	ui.ledt_close->setText(QString::number(pItem.Close));
	//ui.ledt_index->setText(QString::number(pItem.Index));
	std::string kcloseTimeStr = Tools::DateTimeStamp2Str(pItem.CloseTime);
	ui.ledt_closeTime->setText(QString::fromLocal8Bit(kcloseTimeStr.c_str()));
}
